home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d3 / amac33.arc / SRCH21.QM < prev    next >
Text File  |  1991-04-28  |  46KB  |  960 lines

  1. *                               (SRCH21).QM. v2.1a
  2. *┌─────────────────[ (INDEX) Search/Replace Macros ]───────────────────────────┐
  3. *│(CursorLeft)  Wrap cursor to previous line like Wordstar does
  4. *│(CursorRight) Wrap cursor to next       "    "     "       "
  5. *│             [These two macros were written by Tim Farley]
  6. *│
  7. *│@(a)   Moves cursor to first word delimiter after wordleft
  8. *│@(f)   Moves cursor to first word delimiter after wordright
  9. *│^(a_)  Moves cursor to first character of wordleft
  10. *│^(f_)  Moves cursor to first character of wordright
  11. *│
  12. *│@(0) - Srch/rplc from command line, loads files w/SR.BAT,  no prompt
  13. *│@(7) - Srch ONLY from command line, loads files w/SRL.BAT, no replace
  14. *│@(1)─┐ Makes FileList of files containing search text while editing
  15. *│@(2)─┤ Loads FileList of files containing search text while editing
  16. *│@(8)─┘ Srch/rplc while editing loaded files only, prompts,
  17. *│       saves ONLY & keeps loaded ONLY files w/replacements.
  18. *│@(5) - Srch/rplc while editing, finds/loads files, prompts
  19. *│@(9) - Srch ONLY loaded files, keep loaded ONLY files w/ found text
  20. *│
  21. *│@(h) - Select Index item with cursor line, then <enter>.
  22. *│(F4) - RepeatFind
  23. *│(F6) - NextFile
  24. *│
  25. *│(Index) Use      - How to locate macro or item below from Index using @h
  26. *│(Description)    - Search/Replace Macros
  27. *│(Startup)        - What's required
  28. *│(Macros)         - Search/Replace Macros
  29. *│(Other) Macros   - not included
  30. *│(Version) history
  31. *└────────[ be sure to leave at least one blank line at end of Index  ]────────┘
  32.  
  33. * QQQ www for search/replace test
  34.  
  35. *                Confirms  Saves    Must Be
  36. *                Replace-  Loaded   First                       Byte
  37. * Key Run While  ment?     Files?   Macro?      Comments        Size
  38. * ──  ─────────  ────────  ──────   ────── ───────────────────  ────
  39. * @0  cmnd line  no        yes      yes    s/r w/SR.bat         153
  40. * @7  cmnd line  n/a       n/a      yes    load only w/SRL.bat   37
  41. * @1─┐editing    n/a       n/a      no     makes FileList only   99
  42. * @2─┤editing    n/a       n/a      no     loads files only      19
  43. * @8─┘editing    yes       rpl only no     s/r loaded files      41
  44. * @5  editing    yes       rpl only no     s/r finds files      235
  45. * @9  editing    srch only no       no     s/o loaded files      40
  46. * @h  editing    -         -        -      Help locate macros    47
  47.  
  48. * (Index) Use;
  49. *
  50. * To locate a macro or item in this file, press @h, place the cursor
  51. * line on the desired item in the Index above, and press <enter>.
  52. * See BOOK15.QM for more details.
  53.  
  54.  
  55. * (Description):
  56. *
  57. * (SRCH1A) are QEdit macros to search/replace only files containing
  58. * search text from a FileList of file search patterns. Only files
  59. * containing the search text are loaded automatically, and then the
  60. * desired search/replace is performed. Search/replace may also be run
  61. * from the command line and while editing files.
  62.  
  63. * To BEGIN, just type "START SRCH" <Enter>. All pertinent files will be
  64. * loaded in the "Ring" for viewing, and SRCH21.MAC is read.
  65. * Alternatively, type "START SRCH 0" <Enter> and the disk copies of all
  66. * files in the "Ring" will be loaded ready for editing, saving time.
  67.  
  68. * (Startup):
  69. *
  70. * In order for the search/replace macros to run, first  make a
  71. * FileList, SRCH-FG.LST, of the file patterns to be searched.
  72. * Here's mine:
  73.  
  74. *         *.qm
  75. *         *.ql
  76. *         *.inf
  77. *         *.bat
  78. *         *.lst
  79. *         *.me
  80. *         *.doc
  81. *         *.syn
  82. *         e:\syn\sa.syn
  83. *         u:\sr?.bat
  84.  
  85.  
  86. * The SA.SYN entry is my PCED synonym file.
  87.  
  88. * You may want to consider putting only one single file name in the list
  89. * to try these macros, eg TEST.QM.
  90.  
  91. * To perform a search/replace from the command line, type SR, and
  92. * answer the prompts for search and replace text. To perform a SEARCH
  93. * ONLY from the command line, type SRL, and answer the prompts for
  94. * search text. All searches with these macros and batch files are
  95. * non-case sensitive. To perform a case sensitive search, change "IGN"
  96. * to "GN"in the macros below and "-f" to "-fc" in the batch files.
  97.  
  98. * Chris Dunford's excellent FGREP and William Parke's INPUT.COM must be
  99. * located in the path. FGREP can be found on CompuServe IBMAPP Lib 1 as
  100. * FGREP.ARC, v1.71, and on Exec-PC as FGREP172.ZIP. INPUT can be found
  101. * on Exec-PC as INPUT.ZIP. They are probably on many other BBS's also.
  102.  
  103. * When using SR.BAT or SRL.BAT, the message "0 Files copied" means no
  104. * files were found containing the search text, and the macro stops with
  105. * the file c:! loaded but it contains no output from FGREP.
  106.  
  107. * Search and replacement text may be single or multiple words.
  108. *
  109. * Replacing C: with your ram disk will make the macros run faster.
  110.  
  111. * Alt_0/7 set and use the Dos environment variables FGS and FGR. The
  112. * letters "FGS" and "FGR" must NOT occur in any other Dos environment
  113. * variable name or value. You must have enough environment space to
  114. * store both the search and replacement text.
  115.  
  116. * QEdit must be named Q.EXE.
  117.  
  118. * Insert should be ON.
  119.  
  120. * For (other) macros, see ALLMACRO.INF.
  121.  
  122. * These macros require "QEdit and QMAC v2.1, February, 1990" or later.
  123.  
  124.  
  125. * (Macros):--------------------------------------------------------
  126. *
  127. *┌─────────────────────────────────────────────────────────────────────┐
  128. *│ @(0) Macro for search/replace from command line with SR.BAT         │
  129. *└─────────────────────────────────────────────────────────────────────┘
  130. *  ******** MUST BE FIRST MACRO IN FILE FOR START UP IN SR.BAT*********
  131. *            ****** MUST RUN SR.BAT TO USE THIS MACRO******
  132. *
  133. * To do a search/replace from command line, just type SR, and answer
  134. * prompts for search and replacement text.
  135. *
  136. * TEST.QM is included to show how this macro works. Type/enter at the
  137. * command line as follows:
  138. *
  139. *  1.   "SR"  <enter>
  140. *  2.   "aaa" space "bbb" <enter>       (answer SEARCH text prompt)
  141. *  3.   "aaa" space "BBB" <enter>       (answer REPLACEMENT text prompt)
  142.  
  143. * This version of @0 also uses the "Once-Around the ring" technique of
  144. * Kyle Watkins. This macro is smaller and faster than Version 1.8 and
  145. * prior because files are loaded by NextFile rather than EditFile, and
  146. * SET >c:$ is moved to the SR.BAT batch file from the macro.
  147.  
  148. * When finished running with the batch file or PCED, the following
  149. * files are loaded for viewing or editing:
  150. *
  151. * Window 1       -list of files found & search text (output from FGREP)
  152. * Window 2...n+1 -files containing search text, n = (# files found)
  153. *
  154. *
  155. * Temporary file names are:
  156. *
  157. * c:$.ql  List of files found & search text (output from FGREP)
  158. * c:!     Same as c:$.ql
  159. * c:$     Output of Dos SET.
  160. * _       NUL file (NUL file is also ! in some other macros)
  161.  
  162. * When using SR.BAT or SRL.BAT, the message "0 Files copied" means no
  163. * files were found containing the search text, and the macro stops with
  164. * the file c:! loaded but it contains no output from FGREP.
  165. *
  166. @0      MacroBegin
  167. ***************************************** LOAD FILES
  168.         altwordset                      * For all file names
  169.         endfile                         * Get to end of file
  170.  LOADAGAIN:                             *
  171.         unmarkblock                     * Unmark last file name
  172.         find #42 "Fi" return "B"  return* Find file name
  173.  jfalse  END:                           * No find ? quit
  174.         wordright                       * Move to space
  175.         wordright                       * Move to file name
  176.         markcolumn                      * Mark it
  177.         endline                         * Get all name in block
  178.         copy                            * Copy file name to scrap
  179.         EditFile                        * Get ready to load
  180.         CurrentFilename " "             * To force return *here*
  181.         Paste Return                    * Paste file name & do it!
  182.         cursorup                        * Go to next line
  183.  jfalse ENDLOAD:                        * No more filenames? Done load
  184.  jump LOADAGAIN:                        * Check again
  185.  ENDLOAD:                               *
  186.         quit                            * Quit c:! from ring so no rplc
  187. ***************************************** GET SEARCH TEXT TO SCRATCH
  188.         editfile "c:$" return           * Load set output file
  189.         find  "FGS" return return       * Find FGS
  190.         wordright                       * Get to SEARCH text
  191.         markcolumn                      * Begin mark
  192.         endline                         * Mark SEARCH text
  193.         cursorleft                      * No trailing space in block
  194.         storescrbuff "FGS" return       * Store SEARCH text to scratch
  195. ***************************************** GET REPLACE TEXT TO SCRATCH
  196.         unmarkblock                     * Get ready
  197.         begfile                         * Get to top
  198.         find  "FGR" return return       * Find FGR
  199.         wordright                       * Get to REPLACE text
  200.         markcolumn                      * Begin mark
  201.         endline                         * Mark it all
  202.         cursorleft                      * No trailing space in block
  203.         storescrbuff "FGR" return       * Store REPLACE text to scratch
  204.         killfile                        * Kill c:$ for next time
  205.         quit                            * Remove c:$ from ring
  206. ***************************************** BEGIN SEARCH/REPLACE
  207.         Editfile "_" Return             * Insert -or- GoTo NUL File
  208.         getscrbuff "FGS" return cut     * Cut search text from scratch
  209.         Find paste Return escape        * Initialize find prompt
  210.         getscrbuff "FGR" return cut     * Cut replace text from scratch
  211.         FindReplace return              * Begin replacement
  212.         paste return                    * paste REPLACEMENT text
  213. **         "IGN" Return                    ** Replace, no prompt
  214.         Pause Return                    * Allow user input of Options
  215.         Begline Cursorright      * Put cursor in Col. 2 of NUL File
  216.         LOOP:                    * Main test loop
  217.             Nextfile             * Move to next files in Ring
  218.             Cursorleft           * Move cursor left (need for NUL test)
  219.             Jfalse DOIT:         * If couldn't move to left, it's not
  220.                                  * the NUL File AND cursor position
  221.                                  * has not changed -- GO with the
  222.                                  * FindReplace
  223.                                  *ELSE
  224.                                  * Check to see if in the NUL File
  225.             Cursorleft           * Move cursor left for NUL Test
  226.             Jfalse ENDLOOP:      * If couldn't move left -- We
  227.                                  * ARE in the NUL File and Need
  228.                                  * to ENDLOOP
  229.                                  *ELSE
  230.             Cursorright          * Move back to Col. 2 in NUL File
  231.         DOIT:                    * FindReplace Loop
  232.             BegFile              * Move up in case cursor is below find
  233.             Repeatfind           * Do the FindReplace
  234.             Jtrue SAVE:          * If CHANGES are made -- SAVE the File
  235.             Quit                 * If NO CHANGES are made -- QUIT the
  236.                                  * File
  237.             Jump LOOP:           * Return to the Main Loop
  238.         SAVE:                    * Routine to Save a File with Changes
  239.             Savefile             * Save the file
  240.             Jump LOOP:           * Return to Main Loop
  241.         ENDLOOP:                 * Loop is DONE
  242.             Quit                 * Quit the NUL File
  243.   END:                           *
  244.         defaultwordset           * set default
  245. *
  246. * 191 bytes Sun  09-16-1990  15:09:40
  247. * 153 bytes Tue  10-02-1990  18:50:33
  248.  
  249.  
  250.  
  251.  
  252.  
  253. *┌─────────────────────────────────────────────────────────┐
  254. *│ @(1) - makes FileList of files containing search text   │
  255. *└─────────────────────────────────────────────────────────┘
  256. @1      MacroBegin
  257.         Dos 'FGREP -f0 "'               * Make FileList
  258.         Pause                           *
  259.         '">c:! @SRCH-FG.lst'            *
  260.         return return                   *
  261.         editfile "c:!" return quit      * Edit FileList
  262.         editfile return                 *
  263.         begfile                         *
  264.         MarkColumn                      * Mark begfile c:!
  265.         endfile begline                 * Mark endfile col 1
  266.         wordright wordright             * Get to file name
  267.         cursorleft                      * Move off file name
  268.         DeleteBlock                     * Delete file name
  269.         SaveFile                        * Save FileList
  270.         begfile                         * Get to begin
  271.         MarkColumn                      * Mark begfile c:!
  272.         EndFile                         * Get to end
  273.         gotocolumn "12" return          * Get all file names in block
  274.         Sort                            * Sort FileList
  275.         killfile                        * Kill c:!
  276.         begfile                         * See FileList
  277.         unmarkblock                     * Without block mark
  278. *
  279. * 99 bytes Thu  09-13-1990  16:30:45
  280.  
  281.  
  282.  
  283.  
  284. *┌──────────────────────────────────────────────────────────────┐
  285. *│ @(2) - loads FileList of files containing search text        │
  286. *└──────────────────────────────────────────────────────────────┘
  287. * Written by Kyle Watkins, SemWare.
  288. *
  289. @2      MacroBegin
  290. ***************************************** LOAD FileList (from QLSTxx)
  291.         EndFile BegLine                 * Start at last line
  292.  REPEAT:
  293.         UnmarkBlock MarkLine Copy       * Grab this name
  294.         EditFile                        * Get ready to load
  295.         CurrentFilename " "             * To force return *here*
  296.         Paste Return                    * Paste file name & do it!
  297.         CursorUp                        * More lines above?
  298.         JTrue REPEAT:                   * If yes, repeat.
  299. *
  300. * 19 bytes Mon  09-03-1990  00:56:04
  301.  
  302.  
  303.  
  304.  
  305. *┌───────────────────────────────────────────────────────────────────┐
  306. *│ @(5) Makes and loads FileList of files containing search text,    │
  307. *│      then search/replace loaded files while editing               │
  308. *└───────────────────────────────────────────────────────────────────┘
  309. *
  310. @5     MacroBegin
  311. ***************************************** GET SEARCH TEXT
  312.         unmarkblock                     *
  313.         Editfile '!' Return             * Insert -or- GoTo NUL File
  314.        "Search Text=" markcolumn pause  * Search text?
  315.         storescrbuff "1" return copy    * Copy search text to scrap
  316. ***************************************** GET REPLACE TEXT
  317.         RETURN                          * Move to next line
  318.        "Replace Text=" markcolumn pause * Replacement text?
  319.         storescrbuff "2" return         * Store replacement to scratch
  320.         quit                            * Quit NUL
  321. ***************************************** MAKE FileList
  322.         DOS 'FGREP -f0 "'               * Make FileList
  323.         paste                           * Paste search text
  324.         '">c:! @SRCH-FG.lst'            *
  325.         return return                   *
  326.         editfile "c:!" return quit      * Edit FileList
  327.         editfile return                 *
  328.         begfile MarkColumn              * Mark begfile c:!
  329.         endfile begline                 * Mark endfile col 1
  330.  jfalse END:                            * End if no search text found
  331.         wordright wordright             * Get to file name
  332.         cursorleft                      * Move off file name
  333.         DeleteBlock                     * Delete file name
  334.         begfile                         * Get to begin
  335.         MarkColumn                      * Mark begfile c:!
  336.         EndFile                         * Get to end
  337.         gotocolumn "12" return          * Get all file names in block
  338.         Sort                            * Sort FileList
  339. ***************************************** LOAD FileList (from QLSTxx)
  340.         EndFile BegLine                 * Start at last line
  341.  REPEAT:
  342.         UnmarkBlock MarkLine Copy       * Grab this name
  343.         EditFile                        * Get ready to load
  344.         CurrentFilename " "             * To force return *here*
  345.         Paste Return                    * Paste file name & do it!
  346.         CursorUp                        * More lines above?
  347.         JTrue REPEAT:                   * Yes ? repeat
  348.         killfile                        * Kill c:!
  349.         quit                            * Quit c:!
  350.         Editfile '!' Return             * Insert -or- GoTo NUL File
  351.         getscrbuff "1" return cut       * Cut search text from scratch
  352.         Find paste Return escape        * Initialize find prompt
  353.         getscrbuff "2" return cut       * Cut replace text from scratch
  354.         FindReplace return              * Begin replacement
  355.         paste RETURN                    * paste REPLACEMENT text
  356. **         "IGN" Return                    ** Replace, no prompt
  357.         Pause Return                    * Allow user input of Options
  358.         Begline Cursorright      * Put cursor in Col. 2 of NUL File
  359.         LOOP:                    * Main test loop
  360.             Nextfile             * Move to next files in Ring
  361.             Cursorleft           * Move cursor left (need for NUL test)
  362.             Jfalse DOIT:         * If couldn't move to left, it's not
  363.                                  * the NUL File AND cursor position
  364.                                  * has not changed -- GO with the
  365.                                  * FindReplace
  366.                                  *ELSE
  367.                                  * Check to see if in the NUL File
  368.             Cursorleft           * Move cursor left for NUL Test
  369.             Jfalse END:          * If couldn't move left -- We
  370.                                  * ARE in the NUL File and Need
  371.                                  * to END the Macro
  372.                                  *ELSE
  373.             Cursorright          * Move back to Col. 2 in NUL File
  374.         DOIT:                    * FindReplace Loop
  375.             BegFile              * In case cursor is below find
  376.             Repeatfind           * Do the FindReplace
  377.             Jtrue SAVE:          * If CHANGES are made, SAVE the File
  378.             Quit                 * If NO CHANGES are made, QUIT the File
  379.             Jump LOOP:           * Return to the Main Loop
  380.         SAVE:                    * Routine to Save a File with Changes
  381.             Savefile             * Save the file
  382.             Jump LOOP:           * Return to Main Loop
  383.         END:                     * Macro is DONE
  384.             Quit                 * Quit the NUL File
  385. *
  386. * 260 bytes Sun  09-16-1990  14:48:58
  387. * 235 bytes Tue  10-02-1990  23:05:35
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395. * ┌──────────────────────────────────────────────────────────────────┐
  396. * │ @(7) -Start up macro, loads only found files, no replacement     │
  397. * └──────────────────────────────────────────────────────────────────┘
  398. * *** IF USED, MUST BE FIRST MACRO FOR START UP WITH SRL.BAT or PCED***
  399. * ****** MUST RUN SRL.BAT OR PCED TO USE THIS MACRO******
  400.  
  401.  
  402. * This version of this macro is about half the size of @7 in v1.0i and
  403. * runs about twice as fast.
  404.  
  405. * To run, type SRL at the command line and answer prompt for search
  406. * text.
  407. *
  408. * SRL.BAT will accept SRL [search text] as long as [search text] is a
  409. * SINGLE word. This bypasses the need to respond to the INPUT prompt
  410. * for Search Text=. (added in v1.4)
  411. *
  412. * An alternative to using the batch file SRL.BAT is to use the
  413. * following PCED synonym instead:
  414. *
  415. * SYN     SRLFG 'echo off^break on^FGREP -f "&A" @SRCH-FG.LST >c:!
  416. *                ^Q. c:! /Esrl.mac /LSRCH21.mac^break off^echo on'
  417. *
  418. * Just add this synonym to the bottom of your synonym file on one line,
  419. * or type CED SYN SRLFG 'echo ...............'.
  420. *
  421. * To run using PCED, type SRLFG [search text] at the command line.
  422. *
  423. * When finished running with the batch file or PCED, the following
  424. * files are loaded for viewing or editing:
  425. *
  426. * Window 1       -list of files found & search text (output from FGREP)
  427. * Window 2...n+1 -files containing search text, n = (# files found)
  428. *
  429. *
  430. * Temporary file names are:
  431. *
  432. * c:$.ql  List of files found & search text (output from FGREP)
  433. * c:!     Same as c:$.ql
  434. *
  435. * When using SR.BAT or SRL.BAT, the message "(0) Files copied" means no
  436. * files were found containing the search text, and the macro stops with
  437. * the file c:! loaded but it contains no output from FGREP.
  438. *
  439. @7 macrobegin
  440. ***************************************** LOAD FOUND FILES
  441.         altwordset                      * For all file names
  442.         endfile                         * Get to end of file
  443.  CHECKAGAIN:                            *
  444.         unmarkblock                     * Clear last file name
  445.         find #42 "Fi" return "B"  return* Find file name
  446.         wordright                       * Move to space
  447.         wordright                       * Move to file name
  448.         markcolumn                      * Mark it
  449.         endline                         * Get all name in block
  450.         copy                            * Copy file name to scrap
  451.         EditFile                        * Get ready to load
  452.         CurrentFilename " "             * To force return *here*
  453.         Paste Return                    * Paste file name & do it!
  454.         cursorup                        * Go to next line
  455.  jfalse END:                            * No more file names? End
  456.  jump CHECKAGAIN:                       * Check again
  457.  END:                                   *
  458.         defaultwordset                  * Set default
  459. *
  460. * 37 bytes Thu  09-06-1990  13:53:04
  461.  
  462. * ------------------------------------------------------------------------
  463. * @(8)  MACRO TO EXECUTE THE FindReplace ACROSS THE ENTIRE RING OF FILES
  464. *     ----------------------------------------------------------------
  465. *
  466. * See Kyle Watkin's alternate version below for more discussion.
  467.  
  468. @8      Macrobegin
  469.         Editfile '!' Return      * Insert -or- GoTo NUL File
  470.         Findreplace Pause Return * Allow user input of Find Item
  471.         Pause Return             * Allow user input of Replace Item
  472.         Pause Return             * Allow user input of Options
  473.         Begline Cursorright      * Put cursor in Col. 2 of NUL File
  474.         LOOP:                    * Main test loop
  475.             Nextfile             * Move to next files in Ring
  476.             Cursorleft           * Move cursor left (need for NUL test)
  477.             Jfalse DOIT:         * If couldn't move to left, it's not
  478.                                  * the NUL File AND cursor position
  479.                                  * has not changed -- GO with the
  480.                                  * FindReplace
  481.                                  *ELSE
  482.                                  * Check to see if in the NUL File
  483.             Cursorleft           * Move cursor left for NUL Test
  484.             Jfalse END:          * If couldn't move left -- We
  485.                                  * ARE in the NUL File and Need
  486.                                  * to END the Macro
  487.                                  *ELSE
  488.             Cursorright          * Move back to Col. 2 in NUL File
  489.         DOIT:                    * FindReplace Loop
  490.             Begfile              * Needed in case cursor is below Find
  491.             Repeatfind           * Do the FindReplace
  492.             Jtrue SAVE:          * If CHANGES are made -- SAVE the File
  493.             Quit                 * If NO CHANGES made  -- QUIT the File
  494.             Jump LOOP:           * Return to the Main Loop
  495.         SAVE:                    * Routine to Save a File with Changes
  496.             Savefile             * Save the file with CHANGES
  497.             Jump LOOP:           * Return to Main Loop
  498.         END:                     * Macro is DONE
  499.             Quit                 * Quit the NUL File
  500. *
  501. * 62 bytes Sat  09-15-1990  11:17:57 (K. Watkins version)
  502. * 41 bytes Sun  09-30-1990  20:32:55 (this version)
  503.  
  504.  
  505. * * ┌────────────────────────────────────────────────────────────────────┐
  506. * * │@(8)  MACRO TO EXECUTE THE FindReplace ACROSS ENTIRE RING OF FILES  │
  507. * * └────────────────────────────────────────────────────────────────────┘
  508. * *
  509. * * The following macro was written by Kyle Watkins of SemWare in
  510. * * response to my request for a macro to search/replace all loaded
  511. * * files, but also:
  512. * *         - save to disk only those files that had a replacement, and
  513. * *         - keep loaded  only those files that had a replacement made.
  514. * * It is an excellent and creative macro which I urge you to study
  515. * * because of the unique and powerful use of a NUL file as a
  516. * * place-marker.
  517. *
  518. * * ==============================================================================
  519. * * Date: 09-14-90 (11:49)           Number: 9940         SemWare Support BBS
  520. * *   To: TOM HOGSHEAD               Refer#: NONE
  521. * * From: KYLE WATKINS                 Read: NO
  522. * * Subj: ONCE AROUND THE FILE-RING    Conf: (0) Main Board
  523. * * ------------------------------------------------------------------------
  524. * * TH>I have been trying for several months to either modify the following
  525. * * TH>macro or come up with another way to search & replace all loaded
  526. * * TH>files but also to:
  527. * * TH>
  528. * * TH>        - save to disk only those files that had a replacement, and
  529. * * TH>        - keep loaded  only those files that had a replacement made.
  530. * *
  531. * * Hi Tom,
  532. * *     You may need to adjust this macro at the point where I quit the file
  533. * * if no replacements were made to it (The macro can be adjusted to save
  534. * * those files, if there were some pre-existing changes that were present
  535. * * before the macro was envolked). I wasn't sure what you wanted (my own
  536. * * preference is to retain other changes that I made before I envolked this
  537. * * macro -- BUT I wrote the macro to just Quit those files, since that is
  538. * * what I am guessing you want).
  539. * *     Basically, the macro will use the NUL file as a placeholder in the
  540. * * Ring-of-Files. With cursor manipulation, I will determine when you
  541. * * arrive at the NUL file again. Once you get back to the NUL file, the
  542. * * macro will end. Your starting point for the FindReplace throughout the
  543. * * entire Ring will be at the file immediately after the NUL file -- So if
  544. * * you do not have a NUL file already loaded, the starting point will be at
  545. * * the next file from the one that you are currently in. Otherwise, the
  546. * * starting point will be at the next file from the present location of the
  547. * * NUL file.
  548. * *     Note that I always return to the original cursor position, before
  549. * * the FindReplace is executed (allowing you to select any Option for the
  550. * * FindReplace routine).
  551. * *
  552. *
  553. * * ------------------------------------------------------------------------
  554. * *     MACRO TO EXECUTE THE FindReplace ACROSS THE ENTIRE RING OF FILES
  555. * *     ----------------------------------------------------------------
  556. * *
  557. * @8      Macrobegin
  558. *         Editfile 'NUL' Return    * Insert -or- GoTo NUL File
  559. *         Findreplace Pause Return * Allow user input of Find Item
  560. *         Pause Return             * Allow user input of Replace Item
  561. *         Pause Return             * Allow user input of Options
  562. *         Begline Cursorright      * Put cursor in Col. 2 of NUL File
  563. *                                  *
  564. *         LOOP:                    * Main test loop
  565. *                                  *
  566. *             Nextfile             * Move to next files in Ring
  567. *             Cursorleft           * Move cursor left (need for NUL test)
  568. *             Jfalse DOIT:         * If couldn't move to left, it's not
  569. *                                  * the NUL File AND cursor position
  570. *                                  * has not changed -- GO with the
  571. *                                  * FindReplace
  572. *                                  *
  573. *                                  *ELSE
  574. *                                  * Check to see if in the NUL File
  575. *                                  *
  576. *             Editfile
  577. *             'NUL ' Currentfilename Return * GoTo NUL File -- AND--
  578. *                                           * Preload File to Edit
  579. *                                           * Buffer so can Return
  580. *                                           * to Current File
  581. *                                  *
  582. *             Cursorleft           * Move cursor left for NUL Test
  583. *             Jfalse END:          * If couldn't move left -- We
  584. *                                  * ARE in the NUL File and Need
  585. *                                  * to END the Macro
  586. *                                  *
  587. *                                  *ELSE
  588. *             Cursorright          * Move back to Col. 2 in NUL File
  589. *                                  *
  590. *             Editfile
  591. *             Begline Delch Delch Delch Return  * Bring up EditFile Prompt
  592. *                                               * and delete NUL and
  593. *                                               * Return to File we left
  594. *                                  *
  595. *             Cursorright          * Restore Cursor to its previous
  596. *                                  * position and GO with the FindReplace
  597. *                                  *
  598. *         DOIT:                    * FindReplace Loop
  599. *                                  *
  600. *             Repeatfind           * Do the FindReplace
  601. *             Jtrue SAVE:          * If CHANGES are made -- SAVE the File
  602. *                                  *
  603. *             Quit                 * If NO CHANGES are made -- QUIT the
  604. *                                  * File
  605. *                                  *
  606. *             Jump LOOP:           * Return to the Main Loop
  607. *                                  *
  608. *                                  *
  609. *         SAVE:                    * Routine to Save a File with Changes
  610. *                                  *
  611. *             Savefile             * Save the file
  612. *             Jump LOOP:           * Return to Main Loop
  613. *                                  *
  614. *         END:                     * Macro is DONE
  615. *                                  *
  616. *             Quit                 * Quit the NUL File
  617. * *
  618. * * 62 bytes Sat  09-15-1990  11:17:57 (added TH)
  619. *
  620. *
  621. * *      ----------------------------------------------------------------
  622. * *     I hope this is what you need Tom. Feel free to optimize and alter
  623. * * the macro. The main Body of this macro can be used to allow any kind of
  624. * * ONE-TIME File Ring Sweep. I have already used the main body of the macro
  625. * * (with the neccessary adjustments) to Load all files that DO NOT cause a
  626. * * PRESS ESCAPE message -- So I hope it proves useful to you.
  627. * *
  628. * *                              --... ...--
  629. * * .......Kyle Watkins (SemWare Technical Support)
  630.  
  631.  
  632.  
  633.  
  634. * ┌────────────────────────────────────────────────────────┐
  635. * │@(9) Keep loaded only files with "found" text.          │
  636. * └────────────────────────────────────────────────────────┘
  637. *
  638. * This macro uses the same technique developed by Kyle Watkins in @8,
  639. * to keep loaded ONLY files with "found" text. No replacement or save
  640. * is made (@8 makes replacement and saves files with replacements, but
  641. * files without any replacement are QUIT from ring).
  642. *
  643. * Version 1.6 of this macro used RepeatFind in the DOIT loop. If that
  644. * version was executed more than once and the cursor was on the last
  645. * occurence of the search text in a file, RepeatFind would NOT find the
  646. * search text again, and the file was QUIT from the ring. Apparently
  647. * RepeatFind does NOT remember the "G" option with Find.
  648. *
  649. * This version replaces RepeatFind with Find "G". Now, if @9 is executed
  650. * more than once, any file with any occurence of the search text is
  651. * correctly kept loaded.
  652. *
  653. @9      Macrobegin
  654.         Editfile '!' Return      * Insert -or- GoTo NUL File
  655.         Find Pause Return "G"    * Allow user input of Find Item
  656.         Pause Return             * Allow user input of Options
  657.         Begline Cursorright      * Put cursor in Col. 2 of NUL File
  658.         LOOP:                    * Main test loop
  659.             Nextfile             * Move to next files in Ring
  660.             Cursorleft           * Move cursor left (need for NUL test)
  661.             Jfalse DOIT:         * If couldn't move to left, it's not
  662.                                  * the NUL File AND cursor position
  663.                                  * has not changed -- GO with the
  664.                                  * FindReplace
  665.                                  *ELSE
  666.                                  * Check to see if in the NUL File
  667.             Cursorleft           * Move cursor left for NUL Test
  668.             Jfalse END:          * If couldn't move left -- We
  669.                                  * ARE in the NUL File and Need
  670.                                  * to END the Macro
  671.                                  *ELSE
  672.             Cursorright          * Move back to Col. 2 in NUL File
  673.         DOIT:                    * Find Loop
  674.             Find Return "G" return * Do the Find
  675.             Jtrue LOOP:          * If FOUND   -- Return to Main Loop
  676.             Quit                 * If NO FIND -- QUIT the file
  677.             Jump LOOP:           * Return to the Main Loop
  678.         END:                     * Macro is DONE
  679.             Quit                 * Quit the NUL File
  680. *
  681. * 62 bytes Sun  09-16-1990  23:44:00
  682. * 40 bytes Sun  09-30-1990  22:48:24
  683.  
  684.  
  685.  
  686. *┌───────────────────────────────────────────────────────────────────┐
  687. *│@(h) Finds first word on cursor line marked in document below      │
  688. *└───────────────────────────────────────────────────────────────────┘
  689. *
  690. *        @h macro has 2 steps:
  691. *
  692. *        1. Press @ and h at the same time. An ! shows at the
  693. *        end of the top line. Cursor down to desired line in Index.
  694. *
  695. *        2. Press Enter. The macro first erases the !, and
  696. *        then finds the first word on the cursor line in the document
  697. *        below marked with (...).
  698. *
  699. * See BOOK15.QM for more details.
  700. *
  701. @h macrobegin
  702.         unmarkblock                     * Unmark any marked blocks
  703.         begfile endline                 * Go to file begin endline
  704.         "!"                             * Put ! at endline
  705.         begline
  706.         find "!" return return begline  * Highlight !
  707.         pause                           * Pause for Index selection
  708.         wordright markword              * Mark first word on line
  709.         copy                            * Copy word to scrap buffer
  710.         begfile                         * Begfile
  711.         find "!" return return delch    * Find & delete !
  712.         endpara                         * Go to end of Index
  713.         makectrofscreen                 * Cursor line center of window
  714.         find "(" paste ")"
  715.         return "I" return               * Find first marked word in doc
  716.  jfalse NOMARK:
  717.         begline                         * If mark found go to begline
  718.  jump END:
  719.  NOMARK:
  720.         begfile                         * If no mark found go to begfile
  721.  END:
  722. *
  723. * 47 bytes Fri  09-14-1990  14:06:26
  724.  
  725.  
  726.  
  727.  
  728. * =========================================================================
  729. * Date: 10-29-90 (13:26)           Number: 3156         SemWare Support BBS
  730. *   To: EDGAR ESTRADA              Refer#: 3155
  731. * From: TIM FARLEY                   Read: YES
  732. * Subj: Qedit                        Conf: (21) ILink
  733. * ------------------------------------------------------------------------
  734. * EE>I'm interested in finding out how to get Qedit to wordwrap while using
  735. * EE>the right cursor key.
  736. *
  737. * You mean like WordStar does, where it won't let the cursor move
  738. * out into the "empty space" to the right of the lines?
  739. *
  740. * Here are some macros to do this in 2.1:
  741. *
  742. * *
  743. * * Left and Right cursor definitions that wrap to previous/next
  744. * *                line like WordStar does
  745. * *
  746. * (CursorLeft) Macro   (line added TH)
  747. *
  748. cursorleft    MacroBegin     
  749.               CursorLeft     * try to go left
  750.               JTrue end:     * succeed!  then we are done
  751.               CursorUp       * else try to go to prev line
  752.               JFalse end:    * if fail, then at top of file. done.
  753.               EndLine        * jump to end of previous line.
  754.             end:
  755. *
  756. * 13 bytes Mon  10-29-1990  19:33:07 (line added TH)
  757.  
  758.  
  759.  
  760. * (CursorRight) Macro  (line added TH)
  761. *
  762. cursorright   MacroBegin
  763.               EndLine        * are we at end of line?
  764.               JFalse down:
  765.               PrevPosition   * back to where we were
  766.               CursorRight    * and right one
  767.               Jump end:
  768.             down:
  769.               CursorDown     * try to go to next line
  770.               JFalse end:
  771.               BegLine
  772.             end:
  773. *
  774. * 18 bytes Mon  10-29-1990  19:32:57 (line added TH)
  775.  
  776. * NOTE:  You must have the latest registered release of QEdit 2.1
  777. *        to use these macros.  Otherwise you will experience odd
  778. *        side-effects in the menus and other special contexts where
  779. *        the arrow keys have meaning.
  780. *
  781. * There will be an easier way to achieve this behavior in the next
  782. * release of QEdit.
  783. *
  784. * --Tim Farley
  785. *   SemWare Technical Support
  786.  
  787.  
  788. *------------ (Single line macros for QCONFIG.DAT) ----------------
  789.  
  790. * cursorleft MacroBegin CursorLeft JTrue Label0: CursorUp JFalse Label1: EndLine Label0: Label1:
  791.  
  792. * cursorright MacroBegin EndLine JFalse Label0: PrevPosition CursorRight Jump Label1: Label0: CursorDown JFalse Label2: BegLine Label1: Label2:
  793.  
  794.  
  795.  
  796.  
  797.  
  798.  
  799. * Here are four macros that are variations of wordleft and wordright.
  800. * Macros @a and @f position the cursor on the first word delimiter
  801. * after wordleft and wordright. The cursor position will be the space
  802. * following the word as long as no other word delimiter like "," and
  803. * "." etc immediately follows the word. Macros @a and @f do unmark any
  804. * previously marked block, but I don't know any other way to keep this
  805. * from happening. Macros ^a and ^f do almost what wordleft and
  806. * wordright do except the cursor does not stop at the end of a line.
  807. *
  808. *          @a Moves cursor to first word delimiter after wordleft
  809. *          @f Moves cursor to first word delimiter after wordright
  810. *          ^a Moves cursor to first character of wordleft
  811. *          ^f Moves cursor to first charactetr of wordright
  812.  
  813. *┌──────────────────────────────────────────────────────────────┐
  814. *│@(a) Moves cursor to first word delimiter after wordleft      │
  815. *└──────────────────────────────────────────────────────────────┘
  816. @a  macrobegin                          *
  817.     wordleft wordleft                   * Move wordleft twice
  818.     endline                             * Test if on eol
  819.  jtrue NO_EOL:                          * If not on eol, tests true
  820.     wordleft                            * If on eol, goto wordleft
  821.     jump GOTOPOS:                       * Go to end of word
  822.  NO_EOL: prevposition                   * If not at eol, return
  823.  GOTOPOS:                               * to where we were
  824.     markword gotoblockend unmarkblock   * Get to end of word
  825. *
  826. * 18 bytes Mon  10-22-1990  11:32:21
  827.  
  828. *┌─────────────────────────────────────────────────────────────┐
  829. *│@(f) Moves cursor to first word delimiter after wordright    │
  830. *└─────────────────────────────────────────────────────────────┘
  831. @f  macrobegin                          *
  832.     wordright                           * Move wordright
  833.     endline                             * Test if on eol
  834.  jtrue NO_EOL:                          * If not on eol, tests true
  835.     wordright                           * If on eol, goto wordright
  836.     jump GOTOPOS:                       * Go to end of word
  837.  NO_EOL: prevposition                   * If not at eol, return to
  838.  GOTOPOS:                               * where we were
  839.     markword gotoblockend unmarkblock   * Get to end of word
  840. *
  841. * 17 bytes Mon  10-22-1990  11:32:32
  842.  
  843. *┌─────────────────────────────────────────────────────────────┐
  844. *│^(a_) Moves cursor to first character of wordleft            │
  845. *└─────────────────────────────────────────────────────────────┘
  846. ^a  macrobegin                          *
  847.     wordleft                            * Move wordleft
  848.     endline                             * Test if on eol
  849.  jtrue NO_EOL:                          * If not on eol, tests true
  850.     wordleft                            * If on eol, goto wordleft
  851.     jump GOTOPOS:                       * End macro
  852.  NO_EOL: prevposition                   * If not at eol, return to
  853.  GOTOPOS:                               * where we were
  854. *
  855. * 14 bytes Mon  10-22-1990  11:53:14
  856.  
  857. *┌─────────────────────────────────────────────────────────┐
  858. *│^(f_) Moves cursor to first character of wordright       │
  859. *└─────────────────────────────────────────────────────────┘
  860. ^f macrobegin                           *
  861.     wordright                           * Move wordright
  862.     endline                             * Test if on eol
  863.  jtrue NO_EOL:                          * If not on eol, tests true
  864.     wordright                           * If on eol, goto wordright
  865.     jump GOTOPOS:                       * End macro
  866.  NO_EOL: prevposition                   * If not at eol, return to
  867.  GOTOPOS:                               * where we were
  868. *
  869. * 14 bytes Mon  10-22-1990  11:53:03
  870.  
  871.  
  872.  
  873. * (F4)
  874. f4      RepeatFind
  875.  
  876.  
  877. * (F6)
  878. f6      NextFile
  879.  
  880.  
  881. * (VERSION) HISTORY:
  882. *
  883. *       1.0a - Corrected @5 to use @SRCH-FG.lst, not SRCH.lst.
  884. *       1.0b - Modified to not use optional batch file.
  885. *            - Removed @5.
  886. *       1.0c - Added Alt_0 for search/replace from command line.
  887. *            - Modified SRC.BAT, @1 & @4 for case sensitive search.
  888. *            - Modified @4 to re-load search files after replacement.
  889. *            - Corrected @1 byte size.
  890. *       1.0d - Removed redundant lines from @0, shortened 31 bytes
  891. *            - added START-SR.BAT for quick start.
  892. *            - Changed c:srch.ql to c:$.qm in macros and batch files.
  893. *              so as to not overwrite qsrch.ql supplied in SRCHxx.ZIP.
  894. *            - Added killfile c:$.ql to @1 and @4.
  895. *            - Changed FC0 to fc0 in macros and batch files for better
  896. *            - visibility.
  897. *       1.0e - Added @5 for prompted replacement from command line
  898. *            - Added @6 for prompted replacement while editing
  899. *            - Added F4/F6 repeatfind/nextfile
  900. *            - Modified @4 for single search/replacement text input.
  901. *       1.0f - Modified SR.BAT and SRC.BAT
  902. *       1.0g - Modified SR.BAT, SRC.BAT and START-SR.BAT.
  903. *            - Removed INPUT.COM and INPUT.DOC pending author
  904. *              permission to include.
  905. *       1.0h - Removed SRC.BAT, Modified all macros and batch files for
  906. *              NON-case sensitive search
  907. *            - Added @7 and SRL.BAT to only load files with search text,
  908. *              no replacement
  909. *            - Modified SR.BAT to load SRCHxx.MAC on start up.
  910. *       1.0i - Modified @3 to re-load files after replacement.
  911. *            - Modified all macros and batch files for NON-case
  912. *              sensitive search, some had not been changed in v1.0h.
  913. *            - Corrected some macro byte sizes
  914. *       1.0j - Modified comments in SR.BAT, SRL.BAT
  915. *            - Modified @7 to about half the size and twice the speed.
  916. *            - Included a PCED synonym to search/load files with @7.
  917. *       1.1  - Corrected @7 macro size
  918. *            - Removed savefile from old @0
  919. *            - Modified @0 to load FGREP found text, after replacement.
  920. *            - Added [copy c:$.ql c:!] to SR.BAT
  921. *            - Changed FGREP "-f0" to "-f" in SR.BAT, loads found text
  922. *            - Removed @5, same thing can be done with @1/2 and
  923. *              manual search/replace.
  924. *            - Modified srch.ql load filelist for quicker file loading.
  925. *       1.2  - Changed "c:$.ql" to "c:!" in macros @1/4/6, shortened
  926. *              each macro 12 bytes.
  927. *       1.3  - Modified @3 to be smaller and faster.
  928. *       1.4  - Changed "*F" to #42 "Fi" in @0 and @7 to be able to load
  929. *              this file and SRL.QM with SR and SRL.
  930. *            - Modified SRL.BAT to accept SRL [search text] from command
  931. *              as long as [search text] is a SINGLE word.
  932. *            - Added altwordset to @0 and @7 to correctly load file names
  933. *              containing the following characters: !#$%&'(),-./@{}~
  934. *            - Changed .lst and .ql files.
  935. *       1.5  - Removed E:\up from SR.BAT & SRL.BAT
  936. *       1.6  - Added @8 and @9, modified SR.BAT and SRL.BAT.
  937. *            - @3 was deleting first character in loaded files,
  938. *              corrected.
  939. *       1.7  - Added @h to help locate items or macros from Index.
  940. *            - Added @5.
  941. *            - Removed @3, same thing is done better by @8.
  942. *            - Removed @4 and @6, same thing is done better with @5.
  943. *            - Modified @0 to use the "Once-Around the ring"
  944. *              technique developed by Kyle Watkins of SemWare.
  945. *            - Modified SR.BAT and SRL.BAT.
  946. *       1.8  - Replaced RepeatFind w/ Find "G" in @9.
  947. *            - Modified SR.BAT and SRL.BAT.
  948. *       1.9  - Changed Find initialization in @5 and @0.
  949. *            - Modified START-SR.BAT for no search/replace text.
  950. *            - Modified @5, @8, @9 and @0 to be shorter and faster.
  951. *            - Moved SET >c:$ from @0 macro to SR.BAT batch file.
  952. *       2.0  - Added @a, @f, ^a, ^f variations of wordleft & wordright.
  953. *            - Changed quick start file from START-SR to START.
  954. *       2.1  - Added new key definitions for CursorLeft and CursorRight
  955. *              to wrap cursor to previous/next line like Wordstar does.
  956. *            - Changed SEARCH file names to SRCH.
  957. *       2.1a - Corrected Index Use instructions.
  958.  
  959. * Tom Hogshead  Fri  01-11-1991
  960.